package com.kgc.invitation.invitationmanagerservice.service;

import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.kgc.invitation.bean.Invitation;
import com.kgc.invitation.bean.ReplyDetail;
import com.kgc.invitation.bean.ReplyDetailExample;
import com.kgc.invitation.invitationmanagerservice.mapper.ReplyDetailMapper;
import com.kgc.invitation.service.RepService;
import org.apache.dubbo.config.annotation.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class RepServiceImpl implements RepService {
    @Resource
    ReplyDetailMapper replyDetailMapper;
    @Override
    public String getRepByinvid(Integer invid,Integer pageNum) {
        PageHelper.startPage(pageNum,1);
        ReplyDetailExample example=new ReplyDetailExample();
        example.createCriteria().andInvidEqualTo(invid);
        List<ReplyDetail> replyDetails = replyDetailMapper.selectByExample(example);
        PageInfo<ReplyDetail> pageInfo=new PageInfo<>(replyDetails);
        String s= JSONObject.toJSONString(pageInfo, SerializerFeature.WriteMapNullValue,SerializerFeature.DisableCircularReferenceDetect, SerializerFeature.WriteDateUseDateFormat);
        return s;
    }

    @Override
    public Integer addrep(ReplyDetail replyDetail) {
        return replyDetailMapper.insert(replyDetail);
    }

}
